﻿Imports System.Data.SqlClient

Public Class frmExpiringPolicies
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Try
            Me.Cursor = Cursors.WaitCursor

            Dim dap As New SqlDataAdapter("Select ClientNo,ClientName,PolicyNo,EndorsNo,InsurComp," & _
                                               "IssueDate,PeriodFrom,PeriodTo,ClassName,SumInsur,TotalPremium,CompComm,Branch " & _
                                               "From Policies Where " & _
                                               "    PeriodTo>=N'" & Me.DTPPeriodFRm.Value.ToShortDateString & " 00:00:00' " & _
                                               "and PeriodTo<=N'" & Me.DTPPeriodTo.Value.ToShortDateString & " 23:23:59'", cnn)
            Dim das As New DataSet

            cnn.Open()
            dap.Fill(das, "Policies")
            cnn.Close()

            Dim rpt As New ExpiringPolicies
            rpt.SetDataSource(das)
            Me.CrystalReportViewer1.ReportSource = rpt

            Me.Cursor = Cursors.Default
        Catch ex As Exception
            Me.Cursor = Cursors.Default
            If cnn.State = ConnectionState.Open Then
                cnn.Close()
            End If
            MsgBox(ex.ToString)
        End Try
    End Sub

    Private Sub frmPolicyReportsExpiring_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.WindowState = FormWindowState.Maximized
    End Sub
End Class